package com.weave.view;

import javax.swing.*;
import java.awt.*;

public class KeyboardPanel extends JPanel {
    private static final String[][] LAYOUT = {
            {"Q","W","E","R","T","Y","U","I","O","P"},
            {"A","S","D","F","G","H","J","K","L"},
            {"Z","X","C","V","B","N","M"}
    };

    public KeyboardPanel() {
        setLayout(new GridLayout(3, 1, 5, 5));
        setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));

        for (String[] row : LAYOUT) {
            JPanel rowPanel = createKeyboardRow(row);
            add(rowPanel);
        }
    }

    private JPanel createKeyboardRow(String[] keys) {
        JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
        for (String key : keys) {
            JButton btn = new JButton(key);
            btn.setPreferredSize(new Dimension(50, 60));
            btn.setFont(new Font("宋体", Font.BOLD, 18));
            panel.add(btn);
        }
        return panel;
    }
}